<?php

namespace App;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Support\Facades\DB;

class Login extends Model
{
    public function checkLogin($userInfo)
    {
        if (empty($userInfo['username'])){
            return ['code'=>1,'info'=>'请输入管理员账号'];
        }elseif(empty($userInfo['password'])){
            return ['code'=>2,'info'=>'请输入密码'];
        }
        $username = $userInfo['username'];
        $result = DB::select("select * from fs_users where username = '$username'");
        return $result;
//        if (empty($result)){
//            return ['code'=>3,'info'=>'没有此用户'];
//        }elseif ($result['password'] != $userInfo['password']){
//            return ['code'=>3,'info'=>'密码错误'];
//        }
        return ['code'=>0,'info'=>'登陆成功'];
    }
}
